package com.stage.proxy;

import com.stage.annotation.IPerson;
import com.stage.annotation.Person;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
 * Created by Stage on 2017/3/10.
 */
public class StaticPersonProxy implements IPerson {
    private Person person;
    private FileOperation fileWriter = new FileOperation();

    StaticPersonProxy(Person person) {
        this.person = person;
    }

    public void setIdNo(String idNo) {
        fileWriter.fileWriter("Proxy.txt", "时间：" + getNowTime() + "方法名：setIdNo" + "参数：" + idNo);
        this.person.setIdNo(idNo);
    }

    private String getNowTime() {
        java.util.Date date = new java.util.Date();
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = format.format(date);
        return time;
    }
}
